﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;

/// <summary>
/// Summary description for HttpMapping
/// </summary>
public class HttpMapping : System.Web.UI.Page
{
    public HttpMapping()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public HtmlGenericControl CreateControl()
    {
        HtmlGenericControl gel = new HtmlGenericControl("div");
        Control ct;

        string page = GetPage();
        string action = GetAction();
        string pageName = page + action + ".ascx";
        string control = "Controls/Mod_" + page + "/" + pageName;
        try
        {
            ct = Page.LoadControl(control);

        }
        catch (HttpException ex)
        {
            control = "Controls/Warning.ascx";
            ct = Page.LoadControl(control);

        }
        gel.Controls.Add(ct);
        return gel;


    }



    protected string GetPage()
    {
        object o = HttpContext.Current.Request.QueryString["page"];
        return (o == null) ? "Warning" : (string)o.ToString().Trim();
    }

    protected string GetAction()
    {
        object o = HttpContext.Current.Request.QueryString["action"];
        return (o == null) ? "" : (string)o.ToString();
    }

   
}
